<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_voucher.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%
	request.setCharacterEncoding("UTF-8");
	Hashtable ti_voucher = new Hashtable();
	String req_voucher_type="";
	String req_usage_rules="";
	String req_start_time="";
	String req_end_time="";
	
	if(request.getParameter("req_voucher_type")!=null && !request.getParameter("req_voucher_type").equals("")){
		req_voucher_type = request.getParameter("req_voucher_type");
		ti_voucher.put("voucher_type",req_voucher_type);
	}
	if(request.getParameter("req_usage_rules")!=null && !request.getParameter("req_usage_rules").equals("")){
		req_usage_rules = request.getParameter("req_usage_rules");
		ti_voucher.put("usage_rules",req_usage_rules);
	}
	
	if(request.getParameter("req_start_time")!=null && !request.getParameter("req_start_time").equals("")){
		req_start_time = request.getParameter("req_start_time");
		ti_voucher.put("start_time",req_start_time);
	}
	
	if(request.getParameter("req_end_time")!=null && !request.getParameter("req_end_time").equals("")){
		req_end_time = request.getParameter("req_end_time");
		ti_voucher.put("end_time",req_end_time);
	}

	Ti_voucherInfo ti_voucherInfo = new Ti_voucherInfo();
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	List list = ti_voucherInfo.getListByPage(ti_voucher,Integer.parseInt(iStart),limit);
	int counter = ti_voucherInfo.getCountByObj(ti_voucher);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?iStart=",Integer.parseInt(iStart),limit);

	Map rulesMap=new Hashtable();
	Ti_PaymentRulesInfo ti_paymentruleInfo =new Ti_PaymentRulesInfo();
	String rules_select=ti_paymentruleInfo.getSelectString("");
%>
<html>
  <head>
    
    <title>优惠券管理</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="/js/commen.js"></script>
	<script type="text/javascript" src="index.js"></script>
		<script language="javascript" type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>优惠券管理</h1>
			</td>
			<td>
				<a href="addInfo.jsp"><img src="/program/admin/index/images/post.gif" /></a>
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">

	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left" >
				
				
					优惠券类型:<select name="req_voucher_type" id="voucher_type" >
									<option value="">请选择</option>
								  	<%=rules_select%>
						</select>
					使用规则:<select name="req_usage_rules" id="usage_rules" >
									<option value="">请选择</option>
									<option value="1">满额使用</option>
									<option value="2">满量使用</option>
									<option value="3">无条件</option>
						</select>
					开始时间:<input id="start_time" name="req_start_time" type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'end_time\')}',minDate:'%y-%M-%d',readOnly:true})"/>&nbsp;
					结束时间:<input id="end_time" name="req_end_time" type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'start_time\',{d:+1})}',readOnly:true})"/>&nbsp;

				<input name="searchInfo" type="button" value="搜索" onclick="return search('indexForm');"/>	
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center"><input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
			
		  	<th>优惠券类型</th>
		  	
		  	<th>优惠券名称</th>
		  	
		  	<th>使用规则</th>
		  	
		  	<th>开始时间</th>
		  	
		  	<th>结束时间</th>
		  	
		  	<th>金额</th>
		  	
		  	<th>财产类型</th>
		  	
		  	<th>状态</th>
		  	
			<th width="10%">修改</th>
	  		<th width="10%">删除</th>
		</tr>
		
		
		<% 
				List typeList=null;
		  		for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
		  			String voucher_id="",voucher_type="",voucher_name="",usage_rules="",start_time="",end_time="",money="",property_type="",state_code="";
		  			  	if(map.get("voucher_id")!=null) voucher_id = map.get("voucher_id").toString();
					  	if(map.get("voucher_type")!=null) voucher_type = map.get("voucher_type").toString();
					  	if(map.get("voucher_name")!=null) voucher_name = map.get("voucher_name").toString();
					  	if(map.get("usage_rules")!=null) usage_rules = map.get("usage_rules").toString();
					  	if(map.get("start_time")!=null) start_time = map.get("start_time").toString();
						if(start_time.length()>19)start_time=start_time.substring(0,10);
						if(map.get("end_time")!=null) end_time = map.get("end_time").toString();
						if(end_time.length()>19)end_time=end_time.substring(0,10);
						if(map.get("money")!=null) money = map.get("money").toString();
						if(map.get("state_code")!=null) state_code = map.get("state_code").toString();
						if(map.get("property_type")!=null) property_type = map.get("property_type").toString();
		  %>
		
		<tr>
			<td width="5%" align="center"><input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=voucher_id %>" /></td>
			
		  	<td><%
		  		typeList=ti_paymentruleInfo.getListByPk(voucher_type);
		  		if(typeList!=null&&typeList.size()>0){
		  			map=(Hashtable)typeList.get(0);
		  			out.print(map.get("voucher_type"));
		  		}else{
		  			out.print("");
		  		}
		  	%></td>
		  	
		  	<td><%=voucher_name%></td>
		  	
		  	<td width="12%"><%
		  		if(usage_rules.equals("1"))out.print("满额使用");
		  		if(usage_rules.equals("2"))out.print("满量使用");
		  		if(usage_rules.equals("3"))out.print("无条件");
		  	%></td>
		  	
		  	<td width="12%"><%=start_time%></td>
		  	
		  	<td width="12%"><%=end_time%></td>
		  	
		  	<td><%=money%></td>
		  	
		  	<td><%=property_type%></td>
		  	
		  	<td width="10%"><%
		  		if(state_code.equals("0"))out.print("生成");
		  		if(state_code.equals("1"))out.print("领用");
		  		if(state_code.equals("2"))out.print("作废");
		  	%></td>
			<td width="10%"><a href="updateInfo.jsp?voucher_id=<%=voucher_id %>"><img src="/program/admin/images/edit.gif" title="修改" /></a></td>
	  		<td width="10%"><a href="javascript:deleteOneInfo('<%=voucher_id%>','9017');"><img src="/program/admin/images/delete.gif" title="删除" /></a></td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="9017" />
	  </form>
</body>

</html>

